package com.vincent.guava.basics;

import com.google.common.base.Objects;

public class ObjectsTester {
	public int someInt;
	public String someString;
	public long someLong;

	public int getSomeInt() {
		return someInt;
	}

	public void setSomeInt(int someInt) {
		this.someInt = someInt;
	}

	public String getSomeString() {
		return someString;
	}

	public void setSomeString(String someString) {
		this.someString = someString;
	}

	public long getSomeLong() {
		return someLong;
	}

	public void setSomeLong(long someLong) {
		this.someLong = someLong;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + someInt;
		result = prime * result + (int) (someLong ^ (someLong >>> 32));
		result = prime * result
				+ ((someString == null) ? 0 : someString.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ObjectsTester other = (ObjectsTester) obj;
		if (someInt != other.someInt)
			return false;
		if (someLong != other.someLong)
			return false;
		if (someString == null) {
			if (other.someString != null)
				return false;
		} else if (!someString.equals(other.someString))
			return false;
		return true;
	}

	// before
	public String toString_() {
		return "ObjectsTester [someInt=" + someInt + ", someString="
				+ someString + ", someLong=" + someLong + "]";
	}

	// now
	public String toString() {
		return Objects.toStringHelper(this)
				.add("someInt", someInt)
				.add("someString", someString)
				.add("someLong", someLong)
				.toString();
	}

}
